/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : app_freertos.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "usr_inc.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
  .name = "defaultTask",
  .priority = (osPriority_t) osPriorityLow,
  .stack_size = 400 * 4
};
/* Definitions for tossCmdDeal */
osThreadId_t tossCmdDealHandle;
const osThreadAttr_t tossCmdDeal_attributes = {
  .name = "tossCmdDeal",
  .priority = (osPriority_t) osPriorityHigh,
  .stack_size = 240 * 4
};
/* Definitions for dribbleCmdDeal */
osThreadId_t dribbleCmdDealHandle;
const osThreadAttr_t dribbleCmdDeal_attributes = {
  .name = "dribbleCmdDeal",
  .priority = (osPriority_t) osPriorityHigh,
  .stack_size = 240 * 4
};
/* Definitions for nrfUpdate */
osThreadId_t nrfUpdateHandle;
const osThreadAttr_t nrfUpdate_attributes = {
  .name = "nrfUpdate",
  .priority = (osPriority_t) osPriorityHigh,
  .stack_size = 500 * 4
};
/* Definitions for chassisPrintf */
osThreadId_t chassisPrintfHandle;
const osThreadAttr_t chassisPrintf_attributes = {
  .name = "chassisPrintf",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 400 * 4
};
/* Definitions for joyExe */
osThreadId_t joyExeHandle;
const osThreadAttr_t joyExe_attributes = {
  .name = "joyExe",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 240 * 4
};
/* Definitions for chassisSendVel */
osThreadId_t chassisSendVelHandle;
const osThreadAttr_t chassisSendVel_attributes = {
  .name = "chassisSendVel",
  .priority = (osPriority_t) osPriorityAboveNormal,
  .stack_size = 400 * 4
};
/* Definitions for chassisPointExe */
osThreadId_t chassisPointExeHandle;
const osThreadAttr_t chassisPointExe_attributes = {
  .name = "chassisPointExe",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 240 * 4
};
/* Definitions for chassisYawExe */
osThreadId_t chassisYawExeHandle;
const osThreadAttr_t chassisYawExe_attributes = {
  .name = "chassisYawExe",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 240 * 4
};
/* Definitions for chassisCmdDeal */
osThreadId_t chassisCmdDealHandle;
const osThreadAttr_t chassisCmdDeal_attributes = {
  .name = "chassisCmdDeal",
  .priority = (osPriority_t) osPriorityHigh,
  .stack_size = 240 * 4
};
/* Definitions for LocMerge */
osThreadId_t LocMergeHandle;
const osThreadAttr_t LocMerge_attributes = {
  .name = "LocMerge",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 500 * 4
};
/* Definitions for YunqiuSai */
osThreadId_t YunqiuSaiHandle;
const osThreadAttr_t YunqiuSai_attributes = {
  .name = "YunqiuSai",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 500 * 4
};
/* Definitions for chassisYunsuExe */
osThreadId_t chassisYunsuExeHandle;
const osThreadAttr_t chassisYunsuExe_attributes = {
  .name = "chassisYunsuExe",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 700 * 4
};
/* Definitions for DribbleGame */
osThreadId_t DribbleGameHandle;
const osThreadAttr_t DribbleGame_attributes = {
  .name = "DribbleGame",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 550 * 4
};
/* Definitions for DribbleGameErr */
osThreadId_t DribbleGameErrHandle;
const osThreadAttr_t DribbleGameErr_attributes = {
  .name = "DribbleGameErr",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 400 * 4
};
/* Definitions for chassisVelCal */
osThreadId_t chassisVelCalHandle;
const osThreadAttr_t chassisVelCal_attributes = {
  .name = "chassisVelCal",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 300 * 4
};
/* Definitions for DribbleGame2 */
osThreadId_t DribbleGame2Handle;
const osThreadAttr_t DribbleGame2_attributes = {
  .name = "DribbleGame2",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 550 * 4
};
/* Definitions for pidArgsQueue */
osMessageQueueId_t pidArgsQueueHandle;
const osMessageQueueAttr_t pidArgsQueue_attributes = {
  .name = "pidArgsQueue"
};
/* Definitions for tossCmdQueue */
osMessageQueueId_t tossCmdQueueHandle;
const osMessageQueueAttr_t tossCmdQueue_attributes = {
  .name = "tossCmdQueue"
};
/* Definitions for tossStrokeQueue */
osMessageQueueId_t tossStrokeQueueHandle;
const osMessageQueueAttr_t tossStrokeQueue_attributes = {
  .name = "tossStrokeQueue"
};
/* Definitions for dribbleCmdQueue */
osMessageQueueId_t dribbleCmdQueueHandle;
const osMessageQueueAttr_t dribbleCmdQueue_attributes = {
  .name = "dribbleCmdQueue"
};
/* Definitions for locaterMsgBox */
osMessageQueueId_t locaterMsgBoxHandle;
const osMessageQueueAttr_t locaterMsgBox_attributes = {
  .name = "locaterMsgBox"
};
/* Definitions for joyMsgQueue */
osMessageQueueId_t joyMsgQueueHandle;
const osMessageQueueAttr_t joyMsgQueue_attributes = {
  .name = "joyMsgQueue"
};
/* Definitions for chassisJoyVelMsgBox */
osMessageQueueId_t chassisJoyVelMsgBoxHandle;
const osMessageQueueAttr_t chassisJoyVelMsgBox_attributes = {
  .name = "chassisJoyVelMsgBox"
};
/* Definitions for chassisPointVelMsgBox */
osMessageQueueId_t chassisPointVelMsgBoxHandle;
const osMessageQueueAttr_t chassisPointVelMsgBox_attributes = {
  .name = "chassisPointVelMsgBox"
};
/* Definitions for chassisYawVelMsgBox */
osMessageQueueId_t chassisYawVelMsgBoxHandle;
const osMessageQueueAttr_t chassisYawVelMsgBox_attributes = {
  .name = "chassisYawVelMsgBox"
};
/* Definitions for chassisCmdQueue */
osMessageQueueId_t chassisCmdQueueHandle;
const osMessageQueueAttr_t chassisCmdQueue_attributes = {
  .name = "chassisCmdQueue"
};
/* Definitions for chassisPoseCmdQueue */
osMessageQueueId_t chassisPoseCmdQueueHandle;
const osMessageQueueAttr_t chassisPoseCmdQueue_attributes = {
  .name = "chassisPoseCmdQueue"
};
/* Definitions for radarLoc */
osMessageQueueId_t radarLocHandle;
const osMessageQueueAttr_t radarLoc_attributes = {
  .name = "radarLoc"
};
/* Definitions for YunqiuSaiCmdQueue */
osMessageQueueId_t YunqiuSaiCmdQueueHandle;
const osMessageQueueAttr_t YunqiuSaiCmdQueue_attributes = {
  .name = "YunqiuSaiCmdQueue"
};
/* Definitions for DribbleGameCmdQueue */
osMessageQueueId_t DribbleGameCmdQueueHandle;
const osMessageQueueAttr_t DribbleGameCmdQueue_attributes = {
  .name = "DribbleGameCmdQueue"
};
/* Definitions for keyCmdQueue */
osMessageQueueId_t keyCmdQueueHandle;
const osMessageQueueAttr_t keyCmdQueue_attributes = {
  .name = "keyCmdQueue"
};
/* Definitions for locaterVelMsgBox */
osMessageQueueId_t locaterVelMsgBoxHandle;
const osMessageQueueAttr_t locaterVelMsgBox_attributes = {
  .name = "locaterVelMsgBox"
};
/* Definitions for chassisYunsuVelMsgBox */
osMessageQueueId_t chassisYunsuVelMsgBoxHandle;
const osMessageQueueAttr_t chassisYunsuVelMsgBox_attributes = {
  .name = "chassisYunsuVelMsgBox"
};

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

void StartDefaultTask(void *argument);
extern void StartTossCmdDeal(void *argument);
extern void StartDribbleCmdDeal(void *argument);
extern void StartNrfUpdate(void *argument);
extern void StartChassisPrintf(void *argument);
extern void StartJoyExe(void *argument);
extern void StartChassisSendVel(void *argument);
extern void StartChassisPointExe(void *argument);
extern void StartChassisYawExe(void *argument);
extern void StartChassisCmdDeal(void *argument);
extern void StartLocMerge(void *argument);
extern void StartYunqiusai(void *argument);
extern void StartChassisYunsuExe(void *argument);
extern void StartDribbleGame(void *argument);
extern void StartDribbleGameErr(void *argument);
extern void StartchassisVelCal(void *argument);
extern void StartDribbleGame2(void *argument);

void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */

/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* Create the queue(s) */
  /* creation of pidArgsQueue */
  pidArgsQueueHandle = osMessageQueueNew (8, sizeof(PidArgsMsg_t), &pidArgsQueue_attributes);

  /* creation of tossCmdQueue */
  tossCmdQueueHandle = osMessageQueueNew (8, sizeof(TossCmdMsg_t), &tossCmdQueue_attributes);

  /* creation of tossStrokeQueue */
  tossStrokeQueueHandle = osMessageQueueNew (8, sizeof(float), &tossStrokeQueue_attributes);

  /* creation of dribbleCmdQueue */
  dribbleCmdQueueHandle = osMessageQueueNew (8, sizeof(DribbleCmdMsg_t), &dribbleCmdQueue_attributes);

  /* creation of locaterMsgBox */
  locaterMsgBoxHandle = osMessageQueueNew (1, sizeof(LocaterMsg_t), &locaterMsgBox_attributes);

  /* creation of joyMsgQueue */
  joyMsgQueueHandle = osMessageQueueNew (16, sizeof(JoyStickMsg_t), &joyMsgQueue_attributes);

  /* creation of chassisJoyVelMsgBox */
  chassisJoyVelMsgBoxHandle = osMessageQueueNew (1, sizeof(VelMsg_t), &chassisJoyVelMsgBox_attributes);

  /* creation of chassisPointVelMsgBox */
  chassisPointVelMsgBoxHandle = osMessageQueueNew (1, sizeof(VelMsg_t), &chassisPointVelMsgBox_attributes);

  /* creation of chassisYawVelMsgBox */
  chassisYawVelMsgBoxHandle = osMessageQueueNew (1, sizeof(VelMsg_t), &chassisYawVelMsgBox_attributes);

  /* creation of chassisCmdQueue */
  chassisCmdQueueHandle = osMessageQueueNew (8, sizeof(ChassisCmdMsg_t), &chassisCmdQueue_attributes);

  /* creation of chassisPoseCmdQueue */
  chassisPoseCmdQueueHandle = osMessageQueueNew (8, sizeof(PoseMsg_t), &chassisPoseCmdQueue_attributes);

  /* creation of radarLoc */
  radarLocHandle = osMessageQueueNew (1, sizeof(LocaterMsg_t), &radarLoc_attributes);

  /* creation of YunqiuSaiCmdQueue */
  YunqiuSaiCmdQueueHandle = osMessageQueueNew (1, sizeof(YunqiuSai_Command_t), &YunqiuSaiCmdQueue_attributes);

  /* creation of DribbleGameCmdQueue */
  DribbleGameCmdQueueHandle = osMessageQueueNew (1, sizeof(DribbleGame_Command_t), &DribbleGameCmdQueue_attributes);

  /* creation of keyCmdQueue */
  keyCmdQueueHandle = osMessageQueueNew (8, sizeof(KeyCmdMsg_t), &keyCmdQueue_attributes);

  /* creation of locaterVelMsgBox */
  locaterVelMsgBoxHandle = osMessageQueueNew (1, sizeof(LocaterMsg_t), &locaterVelMsgBox_attributes);

  /* creation of chassisYunsuVelMsgBox */
  chassisYunsuVelMsgBoxHandle = osMessageQueueNew (1, sizeof(VelMsg_t), &chassisYunsuVelMsgBox_attributes);

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* creation of defaultTask */
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

  /* creation of tossCmdDeal */
  tossCmdDealHandle = osThreadNew(StartTossCmdDeal, NULL, &tossCmdDeal_attributes);

  /* creation of dribbleCmdDeal */
  dribbleCmdDealHandle = osThreadNew(StartDribbleCmdDeal, NULL, &dribbleCmdDeal_attributes);

  /* creation of nrfUpdate */
  nrfUpdateHandle = osThreadNew(StartNrfUpdate, NULL, &nrfUpdate_attributes);

  /* creation of chassisPrintf */
  chassisPrintfHandle = osThreadNew(StartChassisPrintf, NULL, &chassisPrintf_attributes);

  /* creation of joyExe */
  joyExeHandle = osThreadNew(StartJoyExe, NULL, &joyExe_attributes);

  /* creation of chassisSendVel */
  chassisSendVelHandle = osThreadNew(StartChassisSendVel, NULL, &chassisSendVel_attributes);

  /* creation of chassisPointExe */
  chassisPointExeHandle = osThreadNew(StartChassisPointExe, NULL, &chassisPointExe_attributes);

  /* creation of chassisYawExe */
  chassisYawExeHandle = osThreadNew(StartChassisYawExe, NULL, &chassisYawExe_attributes);

  /* creation of chassisCmdDeal */
  chassisCmdDealHandle = osThreadNew(StartChassisCmdDeal, NULL, &chassisCmdDeal_attributes);

  /* creation of LocMerge */
  LocMergeHandle = osThreadNew(StartLocMerge, NULL, &LocMerge_attributes);

  /* creation of YunqiuSai */
  YunqiuSaiHandle = osThreadNew(StartYunqiusai, NULL, &YunqiuSai_attributes);

  /* creation of chassisYunsuExe */
  chassisYunsuExeHandle = osThreadNew(StartChassisYunsuExe, NULL, &chassisYunsuExe_attributes);

  /* creation of DribbleGame */
  DribbleGameHandle = osThreadNew(StartDribbleGame, NULL, &DribbleGame_attributes);

  /* creation of DribbleGameErr */
  DribbleGameErrHandle = osThreadNew(StartDribbleGameErr, NULL, &DribbleGameErr_attributes);

  /* creation of chassisVelCal */
  chassisVelCalHandle = osThreadNew(StartchassisVelCal, NULL, &chassisVelCal_attributes);

  /* creation of DribbleGame2 */
  DribbleGame2Handle = osThreadNew(StartDribbleGame2, NULL, &DribbleGame2_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_EVENTS */
  /* add events, ... */
  /* USER CODE END RTOS_EVENTS */

}

/* USER CODE BEGIN Header_StartDefaultTask */
/**
  * @brief  Function implementing the defaultTask thread.
  * @param  argument: Not used
  * @retval None
  */
/* USER CODE END Header_StartDefaultTask */
__weak void StartDefaultTask(void *argument)
{
  /* USER CODE BEGIN StartDefaultTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartDefaultTask */
}

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */

/* USER CODE END Application */

